<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        * {
            padding: 0;
            margin: 0;
        }

        html,
        body {
            height: 100%;
        }

        ul,
        li {
            list-style: none;
        }

        .box {
            display: flex;
            justify-content: space-evenly;
            align-items: center;
            height: 0px;
            background: #ddd;
            overflow: hidden;
            transition: all 1s;
        }

        .box1 {
            height: 240px
        }

        .box li {
            width: 300px;
        }

        .box li img {
            width: 100%;
        }
    </style>
</head>
<body>
    <ul class="box" style="background:#ddd no-repeat center center">
        <li><img src="./images/red-betta-fish-1335971.jpg" alt=""></li>
        <li><img src="./images/photo-of-xbox-controller-1365795.jpg" alt=""></li>
        <li><img src="./images/red-dahlia-flower-60597.jpg" alt=""></li>
    </ul>
    <button class="btn">换肤</button>
</body>
<script>
    let btn = document.querySelector('.btn');
    let box = document.querySelector('.box');
    btn.onclick = function(){
        box.classList.toggle('box1');
    }
    box.onclick = function(n){
        document.body.style.background = 'url('+ n.target.src +') no-repeat center center / 100% 100%';
        box.classList.toggle('box1');
    }
</script>
</html>